package UILayer;
import CtrLayer.*;
/*
 * The main menu of the program.
 */
public class MainMenuUI
{
    // instance variables
    private DvdCtr dvdCtr;
    private LoanCtr loanCtr;
    private PersonCtr personCtr;
    private PersonUI pUI;
    private DvdUI dUI;
    private LoanUI lUI;
    private Parser parser;

    public MainMenuUI()
    {
        // initialise instance variables
        dvdCtr = new DvdCtr();
        loanCtr = new LoanCtr();
        personCtr = new PersonCtr();
        parser = new Parser();
        pUI = new PersonUI(personCtr);
        dUI = new DvdUI(dvdCtr);
        lUI = new LoanUI(loanCtr);
    }    

    public void writeMainMenu()
    {
        System.out.println("*** Main Menu ***");
        System.out.println("*   (1) Friend  *");
        System.out.println("*   (2) Dvd's   *");
        System.out.println("*   (3) Loan    *");
        System.out.println("*   (4) Exit    *");
        System.out.println("*****************");
    }

    public void mainMenu()
    {
        boolean exit = false;
        writeMainMenu();
        while(!exit)
        {
            int choice = parser.scanChoiceInput();
            if(choice == 1) { //opret friendMenu
                pUI.personMenu();
                writeMainMenu();
            }
            if(choice == 2) { //opret dvdMenu
                dUI.dvdMenu();
                writeMainMenu();
            }
            if(choice == 3)
            {   //opret loanMenu
                lUI.loanMenu();
                writeMainMenu();
            }
            if(choice == 4) { //Exit program
                System.out.println("Goodbye, have a nice day.");
                exit = true;
            }
        }
    }

}